<template>
    <view>
        <view class="tui-actionsheet-class tui-actionsheet" :class="[show ? 'tui-actionsheet-show' : '']" :style="{ top: `calc(${top}px + 88rpx)` }">
            <!-- :style="{ top: top,bottom: bottom,overflow:overflow }" -->
            <!-- <view>地区信息</view> -->
            <view class="container">

                <view class="body-wrap bh-row bh-justify-space-between">
                    <view class="col-wrap bh-flex-1">
                        <!-- <view class="title">城市</view> -->
                        <view v-for="(item, index) in rentList" :key="index">
                            <view @click="changeIndustry(item)" :class="[selectedDto.value == item.value ? 'col-item col-item-ac' : 'col-item']">{{ item.name }}</view>
                        </view>
                        <!-- <view v-for="(item, index) in industryList" :key="index">
                            <view @click="changeIndustry(item)" :class="[selectedDto.industryId == item.value ? 'col-item col-item-ac' : 'col-item']">{{ item.name }}</view>
                        </view> -->
                    </view>
                </view>
                <view class="btn-wrap bh-row bh-justify-space-between">
                    <view @click="reset" class="btn-reset bh-flex-1">重置</view>
                    <view @click="confirm" class="btn-confirm bh-flex-1">确定</view>
                </view>
            </view>
        </view>
        <view class="tui-actionsheet-mask" style="top:0" :class="[show ? 'tui-mask-show' : '']" @tap="handleClickMask"></view>
    </view>
</template>
 
<script>
import { Api } from '../../api/api'
import { CustomDict } from './custom_dict'
import { Dict } from './dict'

export default {
    name: "showDropRentSheet",
    emits: ['close', 'confirm'],
    props: {
        //点击遮罩 是否可关闭
        maskClosable: {
            type: Boolean,
            default: true
        },
        //显示操作菜单
        show: {
            type: Boolean,
            default: false
        },
        top: {
            type: String,
            default: 0
        },
        initValue: {
            type: Object,
            default: {
            }
        }
    },
    data() {
        return {
            industryList: CustomDict.customDictList(Dict.IndustryTypeEnum),
            rentList: CustomDict.rentList,
            selectedDto: {},
        }
    },
    created() {
        this.selectedDto = CustomDict.getRentDesc(this.initValue.rentMin, this.initValue.rentMax)
    },
    methods: {
        handleClickMask() {
            if (!this.maskClosable) return;
            this.$emit('close')
        },
        changeIndustry(item) {
            if (this.selectedDto.value == item.value) {
                return
            }
            // 这里目前只是北京市
            this.selectedDto = item

        },

        reset() {
            this.selectedDto = { value: 0, name: '' }
        },
        confirm() {
            if (this.selectedDto && this.selectedDto.value) {
                let rentAry = this.selectedDto.value.split('-')
                this.$emit('confirm', { rentMin: rentAry[0], rentMax: rentAry[1] })
            } else {
                this.$emit('confirm', undefined)
            }
        }
    }
}
</script>
 
<style scoped lang="scss">
@import url(../../static/css/base.css);

.tui-actionsheet {
    width: 100%;
    position: fixed;
    left: 0;
    right: 0;
    /* top: 0; */
    z-index: 101;
    visibility: hidden;
    transform: translate3d(0, -100%, 0);
    transform-origin: center;
    transition: all 0.3s ease-in-out;
    background: #eaeaec;
    background: white;
    min-height: 100rpx;
    border-bottom-left-radius: 32rpx;
    border-bottom-right-radius: 32rpx;
}

.tui-actionsheet-show {
    transform: translate3d(0, 0, 0);
    visibility: visible;
}

.tui-tips {
    width: 100%;
    padding: 30rpx 60rpx;
    box-sizing: border-box;
    text-align: center;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tui-operate-box {
    padding-bottom: 12rpx;
}

.tui-actionsheet-btn {
    width: 100%;
    height: 100rpx;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 36rpx;
    position: relative;
}

.tui-btn-last {
    padding-bottom: env(safe-area-inset-bottom);
}

.tui-actionsheet-divider::before {
    content: '';
    width: 100%;
    border-top: 1rpx solid #d9d9d9;
    position: absolute;
    top: 0;
    left: 0;
    -webkit-transform: scaleY(0.5);
    transform: scaleY(0.5);
}

.tui-actionsheet-cancel {
    color: #1a1a1a;
    padding-bottom: env(safe-area-inset-bottom);
}

.tui-actionsheet-hover {
    background: #f7f7f9;
}

.tui-actionsheet-mask {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100;
    transition: all 0.3s ease-in-out;
    opacity: 0;
    visibility: hidden;
}

.tui-mask-show {
    opacity: 1;
    visibility: visible;
}

.container {}

.body-wrap {
    margin-top: 28rpx;

    margin-right: 32rpx;
    font-size: 28rpx;
    font-weight: normal;

    .col-wrap {
        height: 700rpx;
        overflow: scroll;
        // border-right: 1px solid rgba(0, 0, 0, 0.12);
        border-right: 1px solid #f5f5f5;
        // margin-left: 32rpx;

        .title {
            text-align: left;
            margin-bottom: 32rpx;
        }

        .col-item {

            padding: 24rpx 0rpx;
            text-align: left;
            font-size: 28rpx;
            font-weight: normal;
            color: #666666;
            padding-left: 32rpx;
            margin: 0 8rpx;
            border-radius: 8rpx;
        }

        .col-item-ac {
            // font-weight: 600;
            // font-size: 28rpx;
            // color: rgba(0, 0, 0, 0.85);
            font-weight: 600;
            font-size: 28rpx;
            background-color: #F8D247;
        }

        // .col-item {
        //     margin-bottom: 48rpx;
        //     text-align: left;

        //     font-size: 28rpx;
        //     font-weight: normal;

        //     color: #666666;
        // }

        // .col-item-ac {
        //     font-weight: 600;
        //     color: rgba(0, 0, 0, 0.85);
        //     font-size: 28rpx;
        // }
    }
}

.btn-wrap {
    // padding-bottom: 26rpx;
    font-size: 32rpx;
    // border-top: 1px solid rgba(0, 0, 0, 0.12);
    border-top: 1px solid #eee;
    .btn-reset {

        font-weight: normal;

        color: rgba(0, 0, 0, 0.8456);
        text-align: center;
        padding-top: 26rpx;
        padding-bottom: 26rpx;
    }

    .btn-confirm {
        font-weight: 600;
        text-align: center;

        color: rgba(0, 0, 0, 0.85);
        background: #F8D247;
        padding-top: 26rpx;
        padding-bottom: 26rpx;
        border-bottom-right-radius: 30rpx;
    }
}
</style>